#ifndef GY39_H
#define GY39_H

#include <QSerialPort>
#include <QDebug>
#include <QTimer>

class GY39 : public QSerialPort
{
    Q_OBJECT
public:
    static GY39 *get()
    {
        static GY39 g;
        return &g;
    }
    explicit GY39(QObject *parent = nullptr);

    QTimer *timer;
    QByteArray buffer;
    bool verifyChecksum(const QByteArray &data);
    bool verifyChecksum(const QByteArray &data, quint8 crc);
public slots:
    void handleReadyRead();
signals:
    void sigLight(float data);
    void sigData(float, float);
    void sigRecvData(QByteArray);
};

#endif // GY39_H
